package com.quartz.tasks.web.controller;

import com.quartz.tasks.web.vo.Result;
import com.quartz.tasks.web.vo.SystemError;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BaseController {

	protected Logger logger = LoggerFactory.getLogger(getClass());

	/**
	 * 结果
	 */
	Result result;
	/**
	 * 成功-无返回结果
	 * @return
	 */
	protected Result success() {
		return new Result("操作成功!");
	}


	/**
	 * 成功-有返回结果
	 * @param content
	 * @return
	 */
	protected Result success(Object content) {
		result = new Result();
		return result.setContent(content);
	}

	/**
	 * 失败
	 */
	protected Result error() {
		return error(SystemError.SYSTEM_ERROR);
	}
	protected Result error(String code, String message) {
		return new Result(code, message, Result.Status.ERROR);
	}

	protected Result error(SystemError error) {
		return error(error.getCode(), error.getMessage());
	}

	protected Result errorProperties(String propertiesMsg) {
		result = new Result();
		result.setStatus(Result.Status.ERROR.code());
		result.setErrorPropertiesMsg(propertiesMsg);
		return result;
	}


}
